<template>
    <div class="box">
        <h3>组合式API代码中调用vue实例对象</h3>
        <ul>
            <li>通过 import { getCurrentInstance } from "vue"; 加载getCurrentInstance 方法</li>
            <li>getCurrentInstance 只能在组合式api中被直接调用，返回vue监控实例对象</li>
            <li>在需要实例对象的区域通过 getCurrentInstance 返回的对象调用 proxy 属性，加载vue实例</li>
        </ul>
        <input type="button" value="输出当前组件的实例对象" @click="printThis()">
    </div>
</template>

<script setup>
import { getCurrentInstance } from "vue";
const ins = getCurrentInstance();
const { proxy } = getCurrentInstance();  // 不要用，会存在问题


const printThis = function(){
    console.log("printThis:",this)
    console.log("printThis:",this.$options)
    console.log("printThis:",ins )
    console.log("printThis:",ins.proxy )
    console.log("printThis:",proxy )
    console.log("printThis:",ins.$options )
    console.log("printThis:",ins.proxy.$options )
}
</script>

<style lang="sass" scoped>

</style>